angular.module('registerModule', [])
    .controller('registerCtr', ['$scope', 'codeApi', '$location', function ($scope, codeApi, $location) {
        $scope.topTitle = '注册';
        $scope.login = '登录';
        $scope.moreType = '更多注册方式';
        $scope.userName = '用户名';
        $scope.psw = '';
        $scope.agreement = '我以阅读并同意本公司《服务协议》';
        $scope.code = codeApi.getCode();
        $scope.changeCode = function () {
            $scope.code = codeApi.getCode();
        };
        $scope.isRightCode = false;
        $scope.codeBlur = function () {
            $scope.isRightCode = angular.uppercase($scope.codeStr) != angular.uppercase($scope.code);
        };
        $scope.registerFn = function () {
            if ($scope.user && $scope.psw && $scope.codeStr && $scope.check) {
                var userData = LsyStorage.getItem('userDatas');
                userData = userData ? userData : [];
                var userObj={
                    user:$scope.user,
                    psw:$scope.psw
                };
                userData.push(userObj);
                LsyStorage.setItem('userDatas',userData);
                alert('注册成功！');
                $location.path('/login'); //angularjs操作url，不填值表示获取，括号内有内容表示设置并根据内容进行跳转
            }
        };


    }]);